const state = {
  barcodeDetail: {},
}

const mutations = {
  // 添加电池码
  addBarcode(state, { id, data }) {
    let old = state.barcodeDetail[id]
    if (old) {
      old[data.BarcodeData] = data
    } else {
      old = {}
      old[data.BarcodeData] = data
      state.barcodeDetail[id] = old
    }
  },

  // 删除电池码
  removeBarcode(state, { id, BarcodeData }) {
    let old = state.barcodeDetail[id]
    if (old) {
      delete old[BarcodeData]
    }
  },

  // 清空电池列表
  clearBatteryList(state) {
    state.barcodeDetail = {}
  },
}

export default {
  state,
  mutations,
  namespaced: true,
}
